package job

import (
	"time"
)

type RetryOptions func(opts *retryOptions)

type retryOptions struct {
	timeout         time.Duration
	retryNums       int
	isRetryFunc     IsRetryFunc
	retryJetLagFunc RetryJetLagFunc
}

func NewOptions(opts ...RetryOptions) *retryOptions {
	opt := &retryOptions{
		timeout:         DefaultRetryTimeout,
		retryNums:       DefaultRetryCount,
		isRetryFunc:     RetryAlways,
		retryJetLagFunc: RetryJetLagAlways,
	}
	for _, v := range opts {
		v(opt)
	}
	return opt
}

func WithRetryTime(timeout time.Duration) RetryOptions {
	return func(opts *retryOptions) {
		opts.timeout = timeout
	}
}
